# Python for循环及其用法
str = "http://c.biancheng.net/python/"
# for循环，遍历 str 字符串
for ch in str:
    print(ch, end = "")
print()

print("计算 1 + 2 + ... + 100 的结果为：")
# 保存累加结果的变量
result = 0
# 逐个获取从 1 到 100 这些值，并做累加操作
for i in range(101):
    result += i
print(result)
print()

## for循环遍历列表和元组
my_list = [1, 2, 3, 4, 5]
for ele in my_list:
    print("ele =", ele)
print()

my_tuple = (5, 4, 3, 2, 1)
for ele in my_tuple:
    print("ele =", ele)
print()

## for 循环遍历字典
my_dic = {
    "python教程": "http://c.biancheng.net/python/",
    "shell教程": "http://c.biancheng.net/shell",
    "java教程": "http://c.biancheng.net/java/"
}
for ele in my_dic:
    print("ele =", ele)
print()

for ele in my_dic.values():
    print("ele =", ele)
print()

for ele in my_dic.items():
    print("ele =", ele)
